*** Settings ***
Test Setup        common_test_setup    @{crm_contractmessage_menu}
Test Teardown     Run Keyword If Test Failed    common_test_teardown
Resource          ../../resource/workflow.txt
Resource          ../../resource/contractmanage/contractmessage.txt
Resource          ../../testdata/${testenv}/contractmanage/contractmessage.txt

*** Test Cases ***
draft_delete
    ${contract_no}=    kw_crm_produce_draft    @{crm_contract_draft_delete}[0]    试运行
    kw_crm_contract_search    ${True}    \    \    \    ${contract_no}    QA测试
    kw_crm_contract_delete    @{crm_contract_draft_delete}[1]    @{crm_contract_draft_delete}[2]
    table_result_should_be_empty

draft_submit
    ${contract_no}=    kw_crm_produce_draft    @{crm_contract_draft_submit}[0]    试运行
    kw_crm_contract_search    ${True}    \    \    \    ${contract_no}    QA测试
    kw_crm_contract_submit    @{crm_contract_draft_submit}[1]
    table_result_should_be_empty
    select_tabs_bar    审核中
    table_resultnum_should_be    1

draft_modify_and_save_draft
    ${contract_no}=    kw_crm_produce_draft    @{crm_contract_draft_savedraft}[0]    试运行
    kw_crm_contract_search    ${True}    \    \    \    ${contract_no}    QA测试
    @{l}    evaluate    list(@{crm_contract_draft_savedraft})[1:]
    ${filepath}    catenate    SEPARATOR=\\    ${EXECDIR}    testdata    ${testenv}    testload.xlsx
    kw_crm_contract_modify    \    @{l}
    click link new    ${loc_crm_cm_row1_col1_link}
    wait_spin_loaded
    Element Text Should Be New    ${loc_crm_cm_detail_contract_name}    test_修改保存草稿
    click button new    ${modal_button1}
    wait_modal_invisible

draft_modify_and_submit
    ${contract_no}=    kw_crm_produce_draft    @{crm_contract_draft_modify_submit}[0]    试运行
    kw_crm_contract_search    ${True}    \    \    \    ${contract_no}    QA测试
    @{l}    evaluate    list(@{crm_contract_draft_modify_submit})[1:]
    ${filepath}    catenate    SEPARATOR=\\    ${EXECDIR}    testdata    ${testenv}    testload.xlsx
    kw_crm_contract_modify    \    @{l}
    table_result_should_be_empty
    select_tabs_bar    审核中
    table_resultnum_should_be    1

rejected_abandon
    ${contract_no}=    kw_crm_produce_rejected    @{crm_contract_rejected_abandon}[0]    试运行
    kw_crm_contract_search    ${True}    \    \    \    ${contract_no}    QA测试
    @{l}    evaluate    list(@{crm_contract_rejected_abandon})[1:]
    ${filepath}    catenate    SEPARATOR=\\    ${EXECDIR}    testdata    ${testenv}    testload.xlsx
    kw_crm_contract_modify    \    @{l}
    table_result_should_be_empty
    select_tabs_bar    草稿
    table_resultnum_should_be    1

rejected_modify_and_submit
    ${contract_no}=    kw_crm_produce_rejected    @{crm_contract_rejected_modify_submit}[0]    试运行
    kw_crm_contract_search    ${True}    \    \    \    ${contract_no}    QA测试
    @{l}    evaluate    list(@{crm_contract_rejected_modify_submit})[1:]
    ${filepath}    catenate    SEPARATOR=\\    ${EXECDIR}    testdata    ${testenv}    testload.xlsx
    kw_crm_contract_modify    \    @{l}
    table_result_should_be_empty
    select_tabs_bar    审核中
    table_resultnum_should_be    1

rejected_delete
    ${contract_no}=    kw_crm_produce_rejected    @{crm_contract_rejected_delete}[0]    试运行
    kw_crm_contract_search    ${True}    \    \    \    ${contract_no}    QA测试
    kw_crm_contract_delete    @{crm_contract_rejected_delete}[1]    @{crm_contract_rejected_delete}[2]
    table_result_should_be_empty

underreview_cancel
    @{t}    Copy List    ${crm_contract_underreview_cancel}
    ${contract_no}=    kw_crm_produce_underreview    @{t}[0]    试运行
    kw_crm_contract_search    ${True}    \    \    \    ${contract_no}    QA测试
    kw_crm_contract_cancel    @{t}[2]
    table_result_should_be_empty
    select_tabs_bar    草稿
    table_resultnum_should_be    1

underreview_pass
    @{t}    Copy List    ${crm_contract_underreview_pass}
    ${contract_no}=    kw_crm_produce_passed    @{t}[0]    试运行
    kw_crm_contract_search    ${True}    \    \    \    ${contract_no}    QA测试
    select_tabs_bar    @{t}[1]
    table_result_should_be_empty
    select_tabs_bar    已通过
    table_resultnum_should_be    1

passed_file
    @{t}    Copy List    ${crm_contract_passed_file}
    ${contract_no}=    kw_crm_produce_passed    @{t}[0]    试运行
    kw_crm_contract_search    ${True}    \    \    \    ${contract_no}    QA测试
    select_tabs_bar    @{t}[1]
    ${filepath}    catenate    SEPARATOR=\\    ${EXECDIR}    testdata    ${testenv}    testload.xlsx
    ${nowdate}    evaluate    time.strftime('%Y-%m-%d',time.localtime(time.time()))    time
    kw_crm_contract_file    @{t}[1]    ${nowdate}    ${filepath}    @{t}[3]    @{t}[4]    @{t}[5]
    table_result_should_be_empty
    select_tabs_bar    已归档
    table_resultnum_should_be    1

passed_resetting
    @{t}    Copy List    ${crm_contract_passed_resetting}
    ${contract_no}=    kw_crm_produce_passed    @{t}[0]    试运行
    kw_crm_contract_search    ${True}    \    \    \    ${contract_no}    QA测试
    select_tabs_bar    @{t}[1]
    ${filepath}    catenate    SEPARATOR=\\    ${EXECDIR}    testdata    ${testenv}    testload.xlsx
    kw_crm_contract_resetting    @{t}[1]    @{t}[2]    @{t}[3]    @{t}[4]
    table_result_should_be_empty
    select_tabs_bar    草稿
    table_resultnum_should_be    1

filed_file
    [Tags]    notrun
    @{t}    Copy List    ${crm_contract_filed_file}
    kw_crm_produce_filed    @{t}[0]    试运行
    kw_crm_contract_search    ${True}    \    \    \    \    QA测试
    ${contract_no}=    get_table_element_text    1    1    1    /div/span/a
    ${filepath}    catenate    SEPARATOR=\\    ${EXECDIR}    testdata    ${testenv}    testload.xlsx
    kw_crm_contract_file    @{t}[1]    @{t}[2]    ${filepath}    @{t}[3]    @{t}[4]    @{t}[5]

filed_resetting
    [Tags]    notrun
    @{t}    Copy List    ${crm_contract_filed_resetting}
    kw_crm_produce_filed    @{t}[0]    试运行
    kw_crm_contract_search    ${True}    \    \    \    \    QA测试
    ${contract_no}=    get_table_element_text    1    1    1    /div/span/a
    select_tabs_bar    @{t}[1]
    ${filepath}    catenate    SEPARATOR=\\    ${EXECDIR}    testdata    ${testenv}    testload.xlsx
    kw_crm_contract_resetting    @{t}[1]    @{t}[2]    @{t}[3]    @{t}[4]
    table_result_should_be_empty
    select_tabs_bar    草稿
    table_resultnum_should_be    1
